package com.sx.wechat.command.api;

import com.alibaba.fastjson.JSONObject;
import com.sx.wechat.command.cmd.AbstractCommand;
import com.sx.wechat.security.AuthenticationHolder;
import com.sx.wechat.security.CoreWebUtils;
import com.sx.wechat.security.Principal;
import com.sx.wechat.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Created by lihao on 2018/9/25.
 */
@Component("sub_order")
@Transactional
public class Sub_order extends AbstractCommand {
    @Autowired
    JdbcTemplate jdbcTemplate;
    @Autowired
    NamedParameterJdbcTemplate namedParameterJdbcTemplate;
    @Autowired
    OrderService orderService;


    @Override
    public Object executeApi(HttpServletRequest request, HttpServletResponse response) {
        Principal principal= AuthenticationHolder.getCurrent();
        return orderService.sub_order(new JSONObject(CoreWebUtils.requestMap(request)),principal.getId());

    }
}
